<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>编辑</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">

        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">案件名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>案件类型</label>
                        <div class="layui-input-block">
                            <select id="type" name="type" lay-filter="type" ></select>
                            <p class="error" id="type_error" style="margin: 0;"></p>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>案件年度</label>
                        <div class="layui-input-block">
                            <select id="year" name="year" lay-filter="year" ></select>
                            <p class="error" id="year_error" style="margin: 0;"></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>案由</label>
                        <div class="layui-input-block">
                            <input type="text" name="cause" id="cause" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>涉案单位</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=she_unit&type=dept&dept=chan&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="she_unit"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=she_unit&type=dept&dept=chan&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="she_unit_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">涉案项目</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="engin" class="layui-input engin" onclick="openPage('../public/choose_engin.php?dom=engin&page=legal','80%','80%')">
                            <div class="choose_div" id="engin" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_engin.php?dom=engin&page=legal','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">项目负责人</label>
                        <div class="layui-input-block">
                            <input type="text" name="xianger" id="xianger" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">联系方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="xiangtel" id="xiangtel" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>原告</label>
                        <div class="layui-input-block">
                            <input type="text" name="gao_yuan" id="gao_yuan" placeholder="请输入，多个可用“,”隔开" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>被告</label>
                        <div class="layui-input-block">
                            <input type="text" name="gao_bei" id="gao_bei" placeholder="请输入，多个可用“,”隔开" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>诉讼标的(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="biaofee" id="biaofee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">案件跟进人</label>
                        <div class="layui-input-block">
                            <input type="text" name="gener" id="gener" placeholder="请输入，多个可用“,”隔开" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>案件状态</label>
                        <div class="layui-input-block">
                            <div id="zhuang"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>案件进度</label>
                        <div class="layui-input-block">
                            <div class="radio-block" id="jindu">

                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="jindu_3" class="block-generic jindudiv layui-hide">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>准备阶段</span></div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">诉讼准备</label>
                        <div class="layui-input-block">
                            <textarea id="bei_su" name="bei_su" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">诉讼策略</label>
                        <div class="layui-input-block">
                            <textarea id="bei_ce" name="bei_ce" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="jindu_6" class="block-generic jindudiv layui-hide">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>立案</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">立案日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="li_dt" id="li_dt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">受理法院</label>
                        <div class="layui-input-block">
                            <input type="text" name="li_shou" id="li_shou" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">预计诉讼费用(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="li_sufee" id="li_sufee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">案情描述</label>
                        <div class="layui-input-block">
                            <textarea id="li_miao" name="li_miao" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="jindu_9" class="block-generic jindudiv layui-hide">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>一审</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">一审案号</label>
                        <div class="layui-input-block">
                            <input type="text" name="yi_number" id="yi_number" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">一审审理法院</label>
                        <div class="layui-input-block">
                            <input type="text" name="yi_shen" id="yi_shen" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">一审开庭时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="yi_dt" id="yi_dt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">一审诉讼费(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="yi_sufee" id="yi_sufee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">一审案情</label>
                        <div class="layui-input-block">
                            <textarea id="yi_an" name="yi_an" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">一审判决/调解内容</label>
                        <div class="layui-input-block">
                            <textarea id="yi_pan" name="yi_pan" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="jindu_12" class="block-generic jindudiv layui-hide">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>二审</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">二审案号</label>
                        <div class="layui-input-block">
                            <input type="text" name="er_number" id="er_number" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">二审审理法院</label>
                        <div class="layui-input-block">
                            <input type="text" name="er_shen" id="er_shen" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">二审开庭时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="er_dt" id="er_dt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">二审诉讼费(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="er_sufee" id="er_sufee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">二审案情</label>
                        <div class="layui-input-block">
                            <textarea id="er_an" name="er_an" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">二审判决/调解内容</label>
                        <div class="layui-input-block">
                            <textarea id="er_pan" name="er_pan" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="jindu_15" class="block-generic jindudiv layui-hide">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>执行</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">执行案号</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhi_number" id="zhi_number" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">执行法院</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhi_yuan" id="zhi_yuan" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">申请执行日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhi_dt" id="zhi_dt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">执行情况说明</label>
                        <div class="layui-input-block">
                            <textarea id="zhi_shuo" name="zhi_shuo" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="jindu_18" class="block-generic jindudiv layui-hide">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>结案</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">结案时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="jie_dt" id="jie_dt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">诉讼费合计(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="jie_sufee" id="jie_sufee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">结案说明</label>
                        <div class="layui-input-block">
                            <textarea id="jie_shuo" name="jie_shuo" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="block-generic">
            <?php include '../public/upinfo.php'?>
        </div>

    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;


    $("#commentForm").validate({
        rules: {
            cause: {required: true},
            gao_yuan: {required: true},
            gao_bei: {required: true},
            biaofee: {required: true},
        },
        messages:{
            cause: {required: "请输入"},
            gao_yuan: {required: "请输入"},
            gao_bei: {required: "请输入"},
            biaofee: {required: "请输入"},
        }
    });
    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();



        facade.ajax({type: 'get', url: ask_legal_edit, data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;

                $("#name").val(data.name);
                $("#cause").val(data.cause);
                $("#xianger").val(data.xianger);
                $("#xiangtel").val(data.xiangtel);
                $("#gao_yuan").val(data.gao_yuan);
                $("#gao_bei").val(data.gao_bei);
                $("#biaofee").val(data.biaofee);
                $("#gener").val(data.gener);
                $("#explain").val(data.explain);
                $("#bei_su").val(data.bei_su);
                $("#bei_ce").val(data.bei_ce);
                $("#li_dt").val(data.li_dt);
                $("#li_shou").val(data.li_shou);
                $("#li_sufee").val(data.li_sufee);
                $("#li_miao").val(data.li_miao);
                $("#yi_number").val(data.yi_number);
                $("#yi_shen").val(data.yi_shen);
                $("#yi_dt").val(data.yi_dt);
                $("#yi_sufee").val(data.yi_sufee);
                $("#yi_an").val(data.yi_an);
                $("#yi_pan").val(data.yi_pan);
                $("#er_number").val(data.er_number);
                $("#er_shen").val(data.er_shen);
                $("#er_dt").val(data.er_dt);
                $("#er_sufee").val(data.er_sufee);
                $("#er_an").val(data.er_an);
                $("#er_pan").val(data.er_pan);
                $("#zhi_number").val(data.zhi_number);
                $("#zhi_yuan").val(data.zhi_yuan);
                $("#zhi_dt").val(data.zhi_dt);
                $("#zhi_shuo").val(data.zhi_shuo);
                $("#jie_dt").val(data.jie_dt);
                $("#jie_sufee").val(data.jie_sufee);
                $("#jie_shuo").val(data.jie_shuo);




                if(data.she_unit_info.length > 0){
                    tan_tags_init('#she_unit', data.she_unit_info);
                }


                var engin_info = res.data.engin_info;
                if(engin_info){
                    set_choose_btn('engin',engin_info.id,engin_info.name);
                }


                var type_str = '<option value="">请选择</option>';
                var type = res.data.type;
                for (var key in type){
                    if(data.type == key){
                        type_str += '<option value="'+key+'" selected>'+type[key]+'</option>';
                    }else{
                        type_str += '<option value="'+key+'">'+type[key]+'</option>';
                    }
                }
                $("#type").html(type_str);

                var year_str = '<option value="">请选择</option>';
                var year = res.data.year;
                for (var key in year){
                    if(data.year == year[key]){
                        year_str += '<option value="'+year[key]+'" selected>'+year[key]+'</option>';
                    }else{
                        year_str += '<option value="'+year[key]+'">'+year[key]+'</option>';
                    }
                }
                $("#year").html(year_str);


                xmselect_dan('zhuang', res.data.zhuang, data.zhuang, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#zhuang").find('xm-select').removeClass('error');
                    }else{
                        $("#zhuang").find('xm-select').addClass('error');
                    }
                });



                var jindu_str = '';
                var jindu = res.data.state;
                for (var key in jindu){
                    if(in_array(key, res.data.jinduArr)){
                        jindu_str += '<input type="checkbox" name="jindu" lay-filter="jindu" checked lay-skin="primary" value="'+key+'" title="'+jindu[key]+'">';
                        $("#jindu_"+key).removeClass('layui-hide');
                    }else{
                        jindu_str += '<input type="checkbox" name="jindu" lay-filter="jindu" lay-skin="primary" value="'+key+'" title="'+jindu[key]+'">';
                    }
                }
                $("#jindu").html(jindu_str);



                initParseMoney();
                public_upload_file_load('upload_files', res.data.files);
                render_from();
            }
        });


        form.on('select(type)', function(data){
            if(data.value == ''){
                $('#type_error').show().text('请选择');
                $('#type_error').parent().find('input').addClass('select_error');
            }else{
                $('#type_error').hide();
                $('#type_error').parent().find('input').removeClass('select_error');
            }
        });
        form.on('select(year)', function(data){
            if(data.value == ''){
                $('#year_error').show().text('请选择');
                $('#year_error').parent().find('input').addClass('select_error');
            }else{
                $('#year_error').hide();
                $('#year_error').parent().find('input').removeClass('select_error');
            }
        });
        form.on('checkbox(jindu)', function(data){
            var arr = get_checkbox_value('jindu');

            $(".jindudiv").addClass('layui-hide');
            for (var key in arr){
                $("#jindu_"+arr[key]).removeClass('layui-hide');
            }
        });

        form.on('submit(add)', function(data){
            data.field.she_unit = tan_tags_getvalue("#she_unit", 'dept');
            data.field.engin = get_choose_val('engin');

            var validRes = $("#commentForm").valid();

            if(!data.field.she_unit){
                $("#she_unit").parents('.tanxian').addClass('tanerror');
                $('#she_unit_tanerror').text('请选择');
                validRes = false;
            }else{
                $("#she_unit").parents('.tanxian').removeClass('tanerror');
                $('#she_unit_tanerror').text('');
            }

            if(data.field.type == ''){
                $('#type_error').show().text('请选择');
                $('#type_error').parent().find('input').addClass('select_error');
                validRes = false;
            }else{
                $('#type_error').hide();
                $('#type_error').parent().find('input').removeClass('select_error');
            }

            if(data.field.year == ''){
                $('#year_error').show().text('请选择');
                $('#year_error').parent().find('input').addClass('select_error');
                validRes = false;
            }else{
                $('#year_error').hide();
                $('#year_error').parent().find('input').removeClass('select_error');
            }


            if(!data.field.zhuang){
                $("#zhuang").find('xm-select').addClass('error');
                validRes = false;
            }else{
                $("#zhuang").find('xm-select').removeClass('error');
            }

            if(!validRes){return false;}


            data.field.jindu = get_checkbox_value('jindu');


            data = parseMoney(data);
            data.field.id = param_id;
            data.field.files = public_upload_file_value('upload_files');

            facade.ajax({url: ask_legal_edit, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });
            return false;
        });

    });



    function get_checkbox_value() {
        var obj = document.getElementsByName('jindu');
        var s = [];
        for (var i = 0; i < obj.length; i++) {
            if (obj[i].checked){
                s.push(parseInt(obj[i].value))
            }
        }
        return s;
    }
</script>
</body>
</html>
